<?php

require '../utils/conn.php';
include_once '../models/recommand.php';
function getAllRecommands() {

	$query = "SELECT * FROM t_recommand ORDER BY r_timestamp DESC";
	$recommands = array();
	$result = mysql_query($query);
	while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{
		$recommand = new Recommand();
		$recommand->setRecommandId($row['r_id']);
		$recommand->setTitle($row['r_title']);
		$recommand->setStatus($row['r_status']);
		$recommand->setTimestamp($row['r_timestamp']);
		$recommands[] = $recommand;
	}
	return $recommands;
}

function getAllPublishRecommands() {

	$query = "SELECT * FROM t_recommand WHERE r_status=1 ORDER BY r_timestamp DESC";
	$recommands = array();
	$result = mysql_query($query);
	while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{
		$recommand = new Recommand();
		$recommand->setRecommandId($row['r_id']);
		$recommand->setTitle($row['r_title']);
		$recommand->setStatus($row['r_status']);
		$recommand->setTimestamp($row['r_timestamp']);
		$recommands[] = $recommand;
	}
	return $recommands;
}
?>